package homework1.model;

import java.util.ArrayList;

/**
* The grading strategy required
* @author psyomn
*
*/
public class NormalGradingStrategy implements IGradingStrategy<Integer>
{
	/**
	* This is the normal grading strategy as requested from the homework 
	* @param exam the exam grade, also a % of the course
	* @param coursework all components to add (we assume they are %'s of the course)
	* @return Grade ranges A-D, FM if odd grade
	*/
	@Override
	public String generate_grading(Integer exam, ArrayList<Integer> coursework)
	{
		Integer totalmark = new Integer(0); 
		String lettergrade = new String(); 
	
		totalmark = exam; 
	
		for (Integer t : coursework)
		{
			totalmark += t; 
		}
	
		/* 
		I didn't add the other ranges as requested from the homework
		because they are implicitly in effect (since when you jump
		from the first if code block, you know for sure it's not over
		the 70 range).
		*/
	
		if (totalmark > 100)
		{
			lettergrade = "FM";
		}
		else if (totalmark >= 70)
		{
			lettergrade = "A";
		}
		else if (totalmark >= 50)
		{
			lettergrade = "B";
		}
		else if (totalmark >= 30)
		{
			lettergrade = "C"; 
		}
		else if (totalmark >= 0)
		{
			lettergrade = "D";
		}
		else if (totalmark < 0)
		{
			lettergrade = "FM"; 
		}
		else 
		{
			System.out.println("Problem wiht grading.");
		}
	
		return lettergrade;
	}


}
